package com.youtills.action;

import com.youtills.auth.AuthToken;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * TODO - !!!doc me!!!
 *
 * @author ravi.chiluveru
 * @since 23.0 (8/15/14)
 */
public interface ActionContext<Req extends ActionRequest, Res extends ActionResponse> {

    Req getRequest();
    Res getResponse();
    AuthToken getAuthToken();

    class Http implements ActionContext<ActionRequest.Http, ActionResponse.Http> {
        private final ActionRequest.Http request;
        private final ActionResponse.Http response;
        private final AuthToken authToken = null;

        public Http(HttpServletRequest request, HttpServletResponse response) {
            this.request = new ActionRequest.Http(request);
            this.response = new ActionResponse.Http(response);
        }

        @Override
        public ActionRequest.Http getRequest() {
            return request;
        }

        @Override
        public ActionResponse.Http getResponse() {
            return response;
        }

        @Override
        public AuthToken getAuthToken() {
            return authToken;
        }
    }
}
